package cn.crap.springbeans;

import cn.crap.inter.dao.ICacheDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class GetBeanByConfig {

    @Autowired
    private Config config;
    @Resource(name = "memoryCacheDao")
    private ICacheDao memoryCacheDao;
    @Resource(name = "redisCacheDao")
    private ICacheDao redisCacheDao;

    public ICacheDao getCacheDao() {
        if (config.getRedisIp().trim().equals("")) {
            return memoryCacheDao;
        } else {
            return redisCacheDao;
        }
    }
}
